<template>
  <div class="app-page">
    <div class="header">
      <div class="content">
        <div class="h1">跨境直邮 - 海淘省钱首选 - 加拿大飞翔快递</div>
        <div>您身边的物流转运专家 - 华人社区收件、国内订购包邮商品极速发货</div>
      </div>
    </div>
    <div style="flex: 1">
      <el-row style="display: flex; justify-content: center">
        <el-col :md="12">
          <div class="section">
            <div class="title">包裹物流跟踪</div>
            <div class="lines"></div>
            <div class="subtitle">可同时分行跟踪多个运单</div>
            <div class="form-group">
              <el-input
                type="textarea"
                v-model="searchCodes"
                :autosize="{ minRows: 5 }"
                placeholder="请输入运单号"
              ></el-input>
            </div>
            <div class="submit">
              <el-button
                type="primary"
                round
                size="large"
                style="width: 115px"
                @click="handleSubmit"
                >查询</el-button
              >
            </div>
            <br />
            <div class="result">
              <el-radio-group v-model="searchCode" size="large">
                <el-radio-button
                  v-for="list in searchList"
                  :label="list"
                  :key="list"
                ></el-radio-button>
              </el-radio-group>
              <div v-loading="loading" style="margin-top: 20px">
                <div class="tip" v-if="info">
                  <span> 快递类型：{{ info.courierCompany }} </span>
                  <span>
                    订单号：
                    <span style="font-weight: 600">
                      {{ info.orderCode }}
                    </span>
                  </span>
                  <span> 创建时间：{{ info.createTime }} </span>
                  <span> 更新时间：{{ info.statusUpdateTime }} </span>
                </div>
                <el-timeline>
                  <el-timeline-item
                    v-for="(item, index) in data"
                    :key="index"
                    :color="item.color"
                  >
                    <div class="item">
                      <div style="width: 200px">
                        <span> {{ item.time }}</span>
                      </div>
                      <div
                        style="flex: 1"
                        :style="index == 0 ? 'color:#33b391' : 'color:#333'"
                      >
                        {{ item.context }}
                      </div>
                    </div>
                  </el-timeline-item>
                </el-timeline>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import { getKdList, getKdInfo } from "@/api/kd";
export default {
  name: "",
  data() {
    return {
      searchCodes: "",
      searchCode: "",
      searchList: [],
      loading: false,
      data: [],
      info: null,
    };
  },
  components: {},
  mounted() {},
  methods: {
    handleSubmit() {
      let list = this.searchCodes.split(",");
      this.searchCode = list[0];
      this.searchList = list;
    },
  },
  watch: {
    searchCode() {
      this.loading = true;
      getKdInfo(this.searchCode).then((resp) => {
        this.info = resp.data;
      });
      getKdList(this.searchCode).then((resp) => {
        this.loading = false;
        resp.data[0].color = "#33b391";
        resp.data[resp.data.length - 1].color = "#828282";
        this.data = resp.data;
      });
    },
  },
};
</script>

<style lang='scss' scoped>
@import "../../styles/_themeify.scss";
.header {
  background: url("../../assets/img/header.jpg") no-repeat;
  background-size: cover;
  .content {
    padding: 150px 0 50px;
    @include font_color('menuBg');
    text-align: center;
  }
  .h1 {
    @include font_color('menuBg');
    font-size: 42px;
    font-weight: 700;
    margin-bottom: 25px;
  }
  @media (max-width: 767px) {
    .h1 {
      font-size: 18px;
      line-height: 30px;
    }
  }
  @media (max-width: 991px) and (min-width: 768px) {
    .h1 {
      font-size: 28px;
      line-height: 30px;
    }
  }
}
.section {
  padding: 80px 0;
  text-align: center;
  .title {
    font-size: 42px;
    margin-top: 0;
    text-transform: uppercase;
    font-weight: 700;
    color: #333;
  }
  .lines {
    margin: auto;
    width: 70px;
    position: relative;
    border-top: 2px solid #61d2b4;
    margin-top: 15px;
  }
  .subtitle {
    margin-top: 15px;
    color: #333;
    font-size: 14px;
    font-weight: 400;
    margin-bottom: 40px;
  }
  .form-group {
    margin-bottom: 1rem;
  }
  /deep/ .el-textarea__inner {
    border-color: #61d2b4;
    font-size: 16px;
  }
  .submit {
    text-align: center;
  }
  .tip {
    font-size:16px;
    line-height: 30px;
    padding: 8px 16px;
    background-color: #fff6f7;
    border-radius: 4px;
    border-left: 5px solid #61d2b4;
    margin: 20px 0;
    &>span{
      margin-right:10px
    }
  }
  .result {
    .item {
      display: flex;
      line-height: 40px;
      font-size: 16px;
      color: #333;
    }
    text-align: left;
    /deep/ ul.el-timeline {
      padding-left: 20px;
    }
  }
}
</style>
